package com.ydx.eureka.consumer.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @ClassName: Controller
 * @Description:
 * @Author
 * @Date 2021/7/21
 * @Version 1.0
 */
@RestController
@RequestMapping("/eureka-consumer")
public class Controller {
    //idea的纠错机制在解析spring通过命名约定的方式进行配置时,支持的并不是太好，而用Autowired或Resource注入bean时，会报错
    @Resource
    private RestTemplate restTemplate;
    @RequestMapping("/hello")
    public String hello(String s) {
        System.out.println("传入的值为："+s);
        String str = restTemplate.getForObject("http://eureka-service/eureka-service/hello?s=" + s, String.class);
        return "传入的值为："+str;
    }
}
